/*
 * @Author       : huangzb
 * @Date         : 2024-01-25 20:01:08
 * @LastEditors: guangyunl
 * @LastEditTime: 2024-04-01 16:13:24
 * @Description  : 优惠券配置文件
 * @FilePath     : \PcBackend\src\views\CouponsManage\config.js
 */
const validatePass = (rule, value, callback)=>{
  const _rule = /^[0-9]*(\.[0-9]{1,2})?$/;
  if (!_rule.test(value)) {
    callback(new Error("请输入数字"));
  }else{
    callback();
  }
};

const Main_Option = {
    headerAlign: "center",
    align: "center",
    border: true,
    index: true,
    menuWidth: 150,
    // addBtn: false,
    // delBtn: false,
    editBtnIcon: " ",
    delBtnIcon: " ",
    // dialogMenuPosition: 'center',
    // defaultExpandAll:true,
    column: [
        {
            label: "标题",
            prop: "title",
            search: true,
            rules: [
                {
                    required: true,
                    message: "请输入 标题",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "面额/¥",
            prop: "price",
            rules: [
                {
                  required: true,
                  validator: validatePass,
                  trigger: ["blur", "change"],
                },
            ],
        },
        {
            label: "类型",
            prop: "type",
            type: "select",
            search: true,
            dicData: [
                {
                    label: "直减",
                    value: 1,
                },
                {
                    label: "打折",
                    value: 0,
                },
            ],
            rules: [
                {
                    required: true,
                    message: "请选择 类型",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "过期时间",
            prop: "end_time",
            // display: false,
            type: "date",
        },
        {
            label: "新建时间",
            prop: "createdAt",
            display: false,
        },
        {
            label: "最后更新时间",
            prop: "updatedAt",
            display: false,
        },
    ],
};

const Main_Data = [];

export { Main_Option, Main_Data };
